package com.ewanghuiju.app.widget.popupwindow;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.model.bean.local.Bibeibean;
import com.ewanghuiju.app.test.bean.MyPageGridBean;
import com.ewanghuiju.app.ui.home.adapter.IconTitleAdapter;
import com.ewanghuiju.app.util.ToastUtil;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import me.jessyan.autosize.AutoSize;
import razerdp.basepopup.BasePopupWindow;

/**
 * @author sj  qq:751943509
 * @class 首页更多弹框
 * @time 2020/2/19
 */
public class HomemorePopup extends BasePopupWindow {
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    public HomemorePopup(Context context) {
        super(context);
//        AutoSize.cancelAdapt((Activity) context);
        setWidth(getScreenWidth());
        ButterKnife.bind(this, getContentView());
    }

    public void setRecycleView(List<MyPageGridBean> list) {
        recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 4));

        List<Bibeibean> bibeibeans = new ArrayList<>();
        bibeibeans.add(new Bibeibean("我的钱包", R.mipmap.icon_bibei_wdqb));
        bibeibeans.add(new Bibeibean("我的收藏", R.mipmap.icon_bibei_wdsc));
        bibeibeans.add(new Bibeibean("浏览足迹", R.mipmap.icon_bibei_llzj));
        bibeibeans.add(new Bibeibean("邀请好友", R.mipmap.icon_bibei_yqhy));
        bibeibeans.add(new Bibeibean("淘宝授权", R.mipmap.icon_bibei_tbsq));
        bibeibeans.add(new Bibeibean("地推物料", R.mipmap.icon_bibei_dtwl));
        bibeibeans.add(new Bibeibean("常见问题", R.mipmap.icon_bibei_cjwt));
        bibeibeans.add(new Bibeibean("意见反馈", R.mipmap.icon_bibei_yjfk));
        bibeibeans.add(new Bibeibean("商务合作", R.mipmap.icon_bibei_swhz));
        bibeibeans.add(new Bibeibean("客服中心", R.mipmap.icon_bibei_kfzx));
        bibeibeans.add(new Bibeibean("关于我们", R.mipmap.icon_bibei_gywm));
        IconTitleAdapter adapter = new IconTitleAdapter(R.layout.item_icon_title,0);

        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ToastUtil.show("" + position);
            }
        });
        recyclerView.setAdapter(adapter);
        adapter.addData(bibeibeans);
        adapter.notifyDataSetChanged();
    }


    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.popup_home_more);
    }
}
